package com.bytedance.ttnet.a;

import android.content.Context;

import com.bytedance.common.utility.Logger;
import com.bytedance.frameworks.baselib.network.http.util.ProcessUtils;
import com.bytedance.ttnet.hostmonitor.HostStatus;
import com.bytedance.ttnet.hostmonitor.HostMonitorBR;

final class HostMonitorBroadcastReceiver extends HostMonitorBR {
    private final AppConfig a;

    HostMonitorBroadcastReceiver(AppConfig arg1) {
        this.a = arg1;
    }

    public final void a(HostStatus arg7) {
        Context v1;
        NetChannelSelect v0_1;
        if (arg7 != null) {
            try {
                if (!ProcessUtils.b(a.a(this.a))) {
                    return;
                }

                super.a(arg7);
                if (!arg7.isReachable()) {
                    return;
                }

                if (a.b(this.a) == null) {
                    return;
                }

                v0_1 = a.b(this.a);
                v1 = a.a(this.a);
                if (v1 == null) {
                    return;
                }

                if (Logger.debug()) {
                    Logger.d("NetChannelSelect", "select from onConnectivityChange");
                }

                int v2 = NetChannelSelect.d(v1);
                if (v2 == 1) {
                    String v3 = NetChannelSelect.e(v1);
                    if (v3 != null && !v3.equals(v0_1.i)) {
                        v0_1.a(v1, "onConnectivityChange");
                        return;
                    }
                }

                if (v0_1.j != v2) {
                    v0_1.a(v1, "onConnectivityChange");
                }

                if (System.currentTimeMillis() - v0_1.d <= (((long) (v0_1.a * 1000)))) {
                    return;
                }

                v0_1.a(v1, "onConnectivityChange");
                return;
            } catch (Throwable v0) {
                v0.printStackTrace();
            } finally {
                if (!arg7.connectionTypeChanged()) {
                    return;
                }
                a.c(this.a);
            }
        }
    }
}

